package com.yf.catcafe.common;

public class OrderNoGenerator {
    private static final int RANDOM_DIGITS = 6; // 随机数字位数

    public static String generateOrderNo() {
        StringBuilder sb = new StringBuilder();
        // 当前时间戳（毫秒）
        long timestamp = System.currentTimeMillis();
        sb.append(timestamp);

        // 添加随机数
        int random = (int) (Math.random() * Math.pow(10, RANDOM_DIGITS));
        sb.append(String.format("%0" + RANDOM_DIGITS + "d", random));

        return sb.toString();
    }

}
